package com.itheima.day07_Object_oriented_fundamentals;

public class MovieOperator {
    //因为系统中有多部电影，所以电影操作类中，需要有一个movie数组
    private Movie[] movies;
    public MovieOperator(Movie[] movies){
        this.movies = movies;
    }
    //1.展示系统全部电影信息 movies = [m1, m2, m3, ... ];
    public void printAllMovies(){
        System.out.println("---系统全部电影信息如下---");
        for (int i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            System.out.println("m.getId() = " + m.getId());
            System.out.println("m.getName() = " + m.getName());
            System.out.println("m.getPrice() = " + m.getPrice());
            System.out.println("---------------------------------");
        }
    }
    //2.根据电影的编号查询出该电影的详细信息并展示
    public void searchMovieById(int id){
        for (int i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            if (m.getId() == id){
                System.out.println("电影的详细信息如下：");
                System.out.println("m.getId() = " + m.getId());
                System.out.println("m.getName() = " + m.getName());
                System.out.println("m.getPrice() = " + m.getPrice());
                System.out.println("m.getScore() = " + m.getScore());
                System.out.println("m.getDirector() = " + m.getDirector());
                System.out.println("m.getActor() = " + m.getActor());
                System.out.println("m.getInfo() = " + m.getInfo());
                return;//找到就返回
            }
        }
        System.out.println("没有找到编号是" + id + "的电影");
    }
}
